package com.zfei;

import com.mongodb.MongoClient;
import com.mongodb.client.MongoDatabase;

import java.util.Objects;

public class MongoDatabasePolicy {
    private static final String DB_NAME = "test";

    private final MongoDatabase database;
    private final MongoClient client;

    private MongoDatabasePolicy(MongoClient client) {
        this.client = Objects.requireNonNull(client, "client");
        this.database = client.getDatabase(DB_NAME);
    }

    /**
     * Creates an instance based on current maven profile (as defined by {@code -Pit}).
     *
     * @return new instance of the policy to be used by unit tests
     */
    static MongoDatabasePolicy create() {
        final MongoClient client;
        client = new MongoClient();

        return new MongoDatabasePolicy(client);
    }


    MongoDatabase database() {
        return database;
    }


}
